<!--管理员添加学费记录-->
<link rel="stylesheet" href="./css/stadycost.css">

<div class="modal-dialog modal fade" id="submit1">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
			<h4>提示</h4>
		</div>
		<div class="modal-body">
			<p>提交成功！</p>
		</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-primary" class="close" data-dismiss="modal">确认</button>
			<button type="button" class="btn btn-default" class="close" data-dismiss="modal">取消</button>
		</div>
	</div>
</div>
<div class="modal-dialog modal fade" id="shangchuan">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
			<h4>提示</h4>
		</div>
		<div class="modal-body">
			<p>上传成功！</p>
		</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-primary" class="close" data-dismiss="modal">确认</button>
			<button type="button" class="btn btn-default" class="close" data-dismiss="modal">取消</button>
		</div>
	</div>
</div>
<div class="modal-dialog modal fade" id="shibai">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
			<h4>提示</h4>
		</div>
		<div class="modal-body">
			<p>提交失败！</p>
		</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-primary" class="close" data-dismiss="modal">确认</button>
			<button type="button" class="btn btn-default" class="close" data-dismiss="modal">取消</button>
		</div>
	</div>
</div>
<div class="modal-dialog modal fade" id="shangchuan1">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
			<h4>提示</h4>
		</div>
		<div class="modal-body">
			<p>上传失败！</p>
		</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-primary" class="close" data-dismiss="modal">确认</button>
			<button type="button" class="btn btn-default" class="close" data-dismiss="modal">取消</button>
		</div>
	</div>
</div>

<h3 class="text-center">添加学费记录</h3>
<a class="a_jiaofei">添加学生缴费记录></a>
<div class="input-group margintop" id="year">
	<span class="input-group-addon" id="year">学费学年</span>
	<select id="year1">

	</select>
</div>
<div class="input-group  margintop">
	<span class="input-group-addon" id="specialty">专业编号</span>
	<input type="text" id="slid1" class="form-control" placeholder="请填写专业编号" aria-describedby="sizing-addon1">
</div>
<div class="input-group  margintop">
	<span class="input-group-addon" id="specialty">专业名称</span>
	<input type="text" id="specialty1" class="form-control" placeholder="请填写专业名称" aria-describedby="sizing-addon1">
</div>
<div class="input-group margintop">
	<span class="input-group-addon" id="cost">应缴费用</span>
	<input type="text" id="cost1" class="form-control" placeholder="请填写学费费用" aria-describedby="sizing-addon1">
</div>

<button type="button" class="btn btn-primary" id="submit">提交记录</button>
<button id="daoru" type="button" class="btn btn-primary">批量导入记录</button>

<script>
	$('#submit1').on('hidden.bs.modal', function() {
		$('.center').html('');
		$('.center').load('./stadycost.html');
	})

	$(function() { // 初始化内容
		var years = getYearArr(3, 3);
		$.each(years, function(i, n) {
			var str = `
				<option value="` + n + `">` + n + `</option>
			`;

			$('#year1').append(str);
		})
	});

	$('.a_jiaofei').click(function() {
		$('.center').html('');
		$('.center').load('./jiaofei.html');
	})

	$('#submit').click(function() {
		$.ajax({
			xhrFields: {
				withCredentials: true
			},
			type: 'POST',
			url: getFullURL("admin/add-cost"),
			data: {
				year: $("#year1").val(),
				slid: $("#slid1").val(),
				specialty: $('#specialty1').val(),
				cost: $('#cost1').val(),
				sid: "xiangsihu"
			},
			dataType: 'json',
			success: function(data) {
				if(data.status == 0) {
					$('#submit1').modal({
						keyboard: true,
						show: true
					})
				} else if(data.status == -1) {
					$('#shibai').modal({
						keyboard: true,
						show: true
					})
				}
			},
			error: function(err) {
				alert("请求异常，请重新登录！", function() {
					$(location).attr('href', './login.html');
				})
			}
		})
	})

	function getYearArr(start, end) {
		var yearArr = [];
		var myDate = new Date();
		nowYear = myDate.getFullYear(); //当前年
		var startYear = nowYear - start;
		var endYear = nowYear + end;

		for(var it = startYear; it <= endYear; it++) {
			yearArr.push(it);
		}
		return yearArr;
	}
</script>